//Player.h
//Created 13/05/14
//Created By HarryStephenson
//
//This class represents the entirity of the player model, movement and possible
//collision detection (could be handled in a seperate class).

#pragma once

#include "AbstractModel.h"
#include "Globals.h"		// For the correct path files
#include "d3dUtil.h"		// Direct3D stuff
#include "PlayerCamera.h"
#include "Terrain.h"
#include "AbstractQuest.h"
#include "CollisionManager.h"

using namespace std;

//Camera speed multiplier - for debugging. 
#define PLAYER_CAMERA_SPEED_MULTIPLER 25.0f

//The file path of the player model we are using
#define PLAYER_MODEL_FILE_PATH "Models/Kangaroo.obj"
//Where we find the model's textures. 
#define PLAYER_MODEL_TEXTURE_FILE_PATH "Textures/"
// Just define the radian conversion for now
#define TO_RADS 0.0174532925f
#define PI 3.14159265359f

//time a player is invunerable for
#define INITIAL_INVUL_TIME 3.0f

//time the player can attack for
#define INITIAL_ATTACK_TIME 1.0f

// As we did not create our own models the center position for the player model
// is some random point. Beacuse of this we must offset this point by 'some' number
// when attempting to lock the player to the terrain.
#define MODEL_Y_OFFSET 1.0f

//Player will manage the scenes camera class
class VirtualCamera;

// Add graphics interface - a pointer is passed when OnBatchAdd is called
class GraphicsInterface;

// Forward declare our model - Use the static model class as we will not have
// any animations for the model and only one instance of the model can exist 
// in the scene at any given time.
class StaticModel;

// Inherit from the abstract model class
class Player : public AbstractModel
{
public:
	// Standard constructor/destructor
	Player();
	~Player();
	
	// Update the players posistion and other relevent data.
	void Update(float delta);

	// Initalises the player model and loads our data.
	void Init(ID3D11Device* device, 
		XMFLOAT3 position, XMFLOAT3 rotation, XMFLOAT3 scale,
		VirtualCamera* camera, Terrain* gameTerrain);

	// Called by the game scene to add this model to the GraphicsInterface batch.
	void AddToBatch(GraphicsInterface* gi);

	//Gets the players model data
	StaticModel* GetPlayerModel(){return playerModel;};



public:
	// Returns the current posistion of the model
	XMFLOAT3 GetPosition();
	// Returns the desired velocity upon keypress
	XMFLOAT3 GetInput(float frametime, XMFLOAT3 velocity);

	//returns hitbox for collision detection
	AABB GetHitBox();

	void Respawn();

	// Returns the players health. 
	int GetHealth();
	void SetHealth(int New);

	AbstractQuest* GetCurrentQuest();
	void SetCurrentQuest(AbstractQuest* quest);

	bool GetInvunerable();
	void SetInvunerable(bool invun);

	bool GetAttacking();
	void SetAttacking(bool attack);

	int GetDamage();
	void SetDamage(int damage);


private:
	// Pointer for the player model data - We load one from file. 
	// Use static model as we can only have one player model in the scene.
	StaticModel* playerModel;
	// Pointer to the terrain class
	Terrain* terrain;
	//Pointer to the camera this class manages - DO NOT DELETE (Scene will clean up)
	PlayerCamera Camera;

	//pointer to current quest
	AbstractQuest* CurrentQuest;

	//hitbox used for collsion detection
	AABB HitBox;

	//roos health
	int health;

	//bool used to determine whether he player is invunerable to damage
	bool Invunerable;

	//timer used to measure invunerablity time
	float InvunTimer;

	//timer used to measure attacking time
	float AttackingTimer;

	//point the player will respawn it they die
	XMFLOAT3 RespawnPoint;

	//damage the player will inflict
	int Damage;

	//bool used to determien whether the player can deal damage
	bool Attacking;
};